% How to make a grid for 3 
function [zgrid,m]=grid3(stepsize,lowerbound);
agent=3;
upperbound=(1-(agent-1)*lowerbound);

theta=[lowerbound:stepsize:upperbound];

m=length(theta);
r=0;
for k=1:m
    j=r+1;
    r=sum(m:-1:m-(k-1));
    zgrid(1,j:r)=theta(k)*ones(1,r-j+1);
end
r=0;
for k=1:m
    j=r+1;
    r=sum(m:-1:m-(k-1));
    zgrid(2,j:r)=theta(1:(r-j+1));
    zgrid(3,j:r)=theta(m-(k-1):-1:1);
end
zgrid=zgrid';